home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume91
/
libraris
/
smalfprs
/
part02
< prev
Wrap
Internet Message Format
|
1991-03-15
|
24KB
Path: news.larc.nasa.gov!amiga-request
From: amiga-request@ab20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
Subject: v91i063: SmallIFFParse.library - Small IFF Parser library, Part02/02
Reply-To: Michael Jansson <mij@IDA.LiU.SE>
Newsgroups: comp.sources.amiga
Message-ID: <comp.sources.amiga:v91i063@ab20.larc.nasa.gov>
References: <comp.sources.amiga:v91i062@ab20.larc.nasa.gov>
Date: 14 Mar 91 01:46:19 GMT
Approved: tadguy@uunet.UU.NET (Tad Guy)
X-Mail-Submissions-To: amiga@uunet.uu.net
X-Post-Discussions-To: comp.sys.amiga.misc
Submitted-by: Michael Jansson <mij@IDA.LiU.SE>
Posting-number: Volume 91, Issue 063
Archive-name: libraries/smalliffparse/part02
#!/bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 2 (of 2)."
# Contents: binaries/pasteclip.uu sources/handleiff.c
# Wrapped by tadguy@ab20 on Wed Mar 13 20:46:16 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'binaries/pasteclip.uu' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'binaries/pasteclip.uu'\"
else
echo shar: Extracting \"'binaries/pasteclip.uu'\" \(9262 characters\)
sed "s/^X//" >'binaries/pasteclip.uu' <<'END_OF_FILE'
Xbegin 666 pasteclip
XM```#\P`````````#``````````(```6H````QP````$```/I```%J$[Z`Q!.R
XM5?_X2.<X,)?+E<IP`$/Z`98L;(+&3J[]V"E`@LIF#DAZ`95.N@;J6$]@``$R,
XM+&R"RDZN_^(D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O\N3-]``$JL@OQG!B!L@OQ.D$JL@L)G%$CG``(BL
XM+(+"+&R"SDZN_Z9,WT``2JR#!F<((&R#!B"L@PI*K(,.9Q1(YP`"(FR##BQLJ
XM@L9.KOYB3-]``$JL@Q)G%$CG``(B;(,2+&R"QDZN_F),WT``2JR#%F<42.<`)
XM`B)L@Q8L;(+&3J[^8DS?0`!*K(,:9Q1(YP`"(FR#&BQL@L9.KOYB3-]``$CG0
XM``8L>``$""X`!`$I9Q!+^@`(3J[_XF`&0J?S7TYS*E]*K(+@9D!*K(+L9SA(G
XMYP`",&R"ZB`((FR"["QL@L9.KO\N3-]``$CG``(P+(+H4D!(P.6`(FR"Y"QL+
XM@L9.KO\N3-]``&`D2.<``BQL@L9.KO]\3-]``$CG``(B;(+@+&R"QDZN_H9,@
XMWT``2.<``B)L@LXL;(+&3J[^8DS?0``@`RYL@M).=4S?``Q.=4CG("`T+P`,!
XM,`+!_``&)$#5[(+62D)M"K1L@KQL!$J29@XY?``#@P!P_TS?!`1.=0@J``<`L
XM!&822.<``B(2+&R"SDZN_]Q,WT``0I)P`&#:```#[`````$````!```#B@``'
XM``````/R```#Z@```+$`("`@("`@("`@,#`P,#`@("`@("`@("`@("`@("`@C
XM(""00$!`0$!`0$!`0$!`0$!`#`P,#`P,#`P,#$!`0$!`0$`)"0D)"0D!`0$!"
XM`0$!`0$!`0$!`0$!`0$!`4!`0$!`0`H*"@H*"@("`@("`@("`@("`@("`@("N
XM`@("0$!`0"``````````````````````````````````````````````````F
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM```````````````````"`````````0``````````````````!``!``````$`)
XM``````````````````0``@`````!````````````````````````````````'
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM`````````````````````````````````````````````````````````````
XM```````````````````````````````````````````````````4````````4
X2``````/R```#ZP````$```/R9
X``
Xend
Xsize 6588
END_OF_FILE
if test 9262 -ne `wc -c <'binaries/pasteclip.uu'`; then
echo shar: \"'binaries/pasteclip.uu'\" unpacked with wrong size!
fi
# end of 'binaries/pasteclip.uu'
fi
if test -f 'sources/handleiff.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'sources/handleiff.c'\"
else
echo shar: Extracting \"'sources/handleiff.c'\" \(11025 characters\)
sed "s/^X//" >'sources/handleiff.c' <<'END_OF_FILE'
X/*
X**
X**
X**
X**
X**
X*/
X#include "handleiff.h"
X#include "undefs.h"
X#include "iffparse.pra"
X#include <ctype.h>
X
X/*#####################*\
X * Internal functions. *
X\*#####################*/
X/****************************\
X * Name: SeekStream *
X * Function: Move forward *
X * or backward in the file *
X * or in the clipboard *
X * relative where we are. *
X\****************************/
Xlong
XSeekStream(struct IFF *iff, long delta)
X{
X long error;
X
X geta4();
X TraceCall;
X if (iff->iff_Type==IOREQUEST) {
X IOReq(iff)->io_Offset += delta;
X error = SUCCESS;
X } else {
X if ((error = Seek(File(iff), delta, (long)OFFSET_CURRENT))>0)
X error = SUCCESS;
X }
X return error;
X}
X
X/*******************************\
X * Name: WriteStream *
X * Function: Write data to the *
X * stream (a file or the clip- *
X * board). *
X\*******************************/
Xlong
XWriteStream(
X struct IFF *iff,
X UBYTE *data,
X long length)
X{
X long error;
X
X geta4();
X TraceCall;
X if (iff->iff_Type==IOREQUEST) {
X IOReq(iff)->io_Command = CMD_WRITE;
X IOReq(iff)->io_Data = (UBYTE *)data;
X IOReq(iff)->io_Length = (long)length;
X DoClipIO(IOReq(iff));
X error = (long)-IOReq(iff)->io_Error;
X } else {
X error = Write(File(iff), (char *)data, length);
X }
X if (error>0)
X error = 0L;
X return error;
X}
X
X/********************************\
X * Name: ReadStream *
X * Function: Read data from the *
X * device (a file or the clip- *
X * board). *
X\********************************/
Xlong
XReadStream(struct IFF *iff, UBYTE *data, long length)
X{
X long error;
X
X geta4();
X TraceCall;
X if (iff->iff_Type==IOREQUEST) {
X IOReq(iff)->io_Command = CMD_READ;
X IOReq(iff)->io_Data = (UBYTE *)data;
X IOReq(iff)->io_Length = (long)length;
X DoClipIO(IOReq(iff));
X if (IOReq(iff)->io_Error==0)
X error = IOReq(iff)->io_Actual;
X else
X error = (long)-IOReq(iff)->io_Error;
X } else {
X error = Read(File(iff), (char *)data, length);
X }
X return error;
X}
X
X/********************************\
X * Name: AlignStream *
X * Function: Align the read *
X * data so that it will be an *
X * even number of bytes. *
X\********************************/
Xlong
XAlignStream(struct IFF *iff)
X{
X long error;
X
X geta4();
X TraceCall;
X if (iff->iff_Type==IOREQUEST) {
X if (IOReq(iff)->io_Offset%2)
X IOReq(iff)->io_Offset++;
X error = 0L;
X } else {
X if (Seek(File(iff), 0L, (long)OFFSET_CURRENT)%2)
X error = Seek(File(iff), 1L, (long)OFFSET_CURRENT);
X }
X if (error>0L)
X error = 0L;
X return error;
X}
X
X
X/*############################*\
X * Public iffparse functions. *
X\*############################*/
X/********************\
X * Initializations. *
X\********************/
Xlong
XInitIFFasClip(struct IFF *iff)
X{
X geta4();
X TraceCall;
X iff->iff_Type = IOREQUEST;
X return SUCCESS;
X}
X
Xlong
XInitIFFasDOS(struct IFF *iff)
X{
X geta4();
X TraceCall;
X iff->iff_Type = FILEHANDLE;
X return SUCCESS;
X}
X
Xlong
XOpenIFF(struct IFF *iff, long rwmode)
X{
X geta4();
X TraceCall;
X IFFptr = 0;
X IFFStack[0].Size = 0;
X iff->iff_Flags = rwmode;
X if (iff->iff_Type==IOREQUEST) {
X if (rwmode==IFFF_READ)
X IOReq(iff)->io_Command = CMD_READ;
X else
X IOReq(iff)->io_Command = CMD_WRITE;
X IOReq(iff)->io_Offset = 0;
X IOReq(iff)->io_ClipID = 0;
X }
X return SUCCESS;
X}
X
Xvoid
XCloseIFF(struct IFF *iff)
X{
X geta4();
X TraceCall;
X if (iff->iff_Type==IOREQUEST) {
X if ((iff->iff_Flags&IFFF_RWBITS)==IFFF_WRITE) { /* Make the clip public. */
X IOReq(iff)->io_Command = CMD_UPDATE;
X DoClipIO(IOReq(iff));
X } else { /* Flush the stuff that is not used. */
X long dummy;
X while (IOReq(iff)->io_Actual && !IOReq(iff)->io_Error) {
X IOReq(iff)->io_Data = (STRPTR)&dummy;
X IOReq(iff)->io_Length = 4;
X DoClipIO(IOReq(iff));
X }
X }
X }
X}
X
Xstruct IFF *
XAllocIFF(void)
X{
X struct IFF *iff;
X
X geta4();
X TraceCall;
X iff = NULL;
X if ((iff = AllocMem((long)sizeof(struct IFF), MEMF_PUBLIC|MEMF_CLEAR))==NULL)
X return NULL;
X
X if ((iff->iff_Stack = AllocMem((long)sizeof(long)*256L, 0L))==NULL) {
X FreeMem((APTR)iff, (long)sizeof(struct IFF));
X iff = NULL;
X }
X return iff;
X}
X
Xvoid
XFreeIFF(struct IFF *iff)
X{
X geta4();
X TraceCall;
X if (iff) {
X if (iff->iff_Stack)
X FreeMem((APTR)iff->iff_Stack, (long)sizeof(long)*256L);
X FreeMem((APTR)iff, (long)sizeof(struct IFF));
X }
X}
X
Xstruct CBHandle *
XOpenClipboard(long unit)
X{
X struct Library *IFFParseBase;
X struct CBHandle *ch = NULL;
X
X geta4();
X TraceCall;
X if ((ch = AllocMem((long)sizeof(struct CBHandle), MEMF_CLEAR))==NULL)
X goto fail;
X if ((ch->cbh_CBport = CreatePort(0L, 0L))==NULL)
X goto fail;
X if ((ch->cbh_SatisfyPort = CreatePort(0L, 0L))==NULL)
X goto fail;
X if ((ch->cbh_Req = (struct IOClipReq *)CreateExtIO(ch->cbh_CBport,
X (long)sizeof(struct IOClipReq)))==NULL)
X goto fail;
X if (OpenDevice("clipboard.device", unit, (struct IORequest *)ch->cbh_Req, 0L)) {
X DeleteExtIO((struct IORequest *)ch->cbh_Req);
X ch->cbh_Req = NULL;
X goto fail;
X }
X
X return ch;
X
Xfail:
X CloseClipboard(ch);
X return NULL;
X}
X
Xvoid
XCloseClipboard(struct CBHandle *ch)
X{
X geta4();
X TraceCall;
X if (ch->cbh_Req) {
X CloseDevice((struct IORequest *)ch->cbh_Req);
X DeleteExtIO((struct IORequest *)ch->cbh_Req);
X ch->cbh_Req = NULL;
X }
X if (ch->cbh_CBport)
X DeletePort((struct MsgPort *)ch->cbh_CBport);
X if (ch->cbh_SatisfyPort)
X DeletePort((struct MsgPort *)ch->cbh_SatisfyPort);
X if (ch)
X FreeMem((APTR)ch, (long)sizeof(struct CBHandle));
X}
X
X/*************************\
X * Miscelous functions . *
X\*************************/
Xlong
XNOOP()
X{
X geta4();
X TraceCall;
X return FAILED;
X}
X
Xvoid *
XNULL_NOOP()
X{
X geta4();
X TraceCall;
X return NULL;
X}
X
XUBYTE *
XIDtoStr(long ID, UBYTE *buf)
X{
X geta4();
X TraceCall;
X *((long *)buf) = ID;
X buf[4] = '\0';
X return buf;
X}
X
X#define ValidChar(l) (isalpha(l) || ((l)==' '))
X
Xlong
XGoodID(long ID)
X{
X char *str = (char *)&ID;
X
X geta4();
X TraceCall;
X return (long)(ValidChar(str[0])
X && ValidChar(str[1])
X && ValidChar(str[2])
X && ValidChar(str[3]));
X}
X
Xlong
XGoodType(long ID)
X{
X char *str = (char *)&ID;
X
X geta4();
X TraceCall;
X return (long)(ValidChar(str[0])
X && ValidChar(str[1])
X && ValidChar(str[2])
X && ValidChar(str[3]));
X}
X
X/************************\
X * The 'big' functions. *
X\************************/
Xlong
XWriteChunkBytes(
X struct IFF *iff,
X APTR data,
X long size)
X{
X long datasize = size; /* Due to Manx bug! */
X
X geta4();
X TraceCall;
X if (WriteStream(iff, (UBYTE *)data, datasize))
X return IFFERR_READ;
X IFFStack[IFFptr].Size += datasize;
X return 0L;
X}
X
Xlong
XReadChunkBytes(
X struct IFF *iff,
X APTR data,
X size_t size)
X{
X long error;
X long datasize = size; /* Due to Manx bug! */
X
X geta4();
X TraceCall;
X if (data==NULL) {
X return IFFERR_SYNTAX;
X } else {
X if ((datasize==0) || (datasize>IFFStack[IFFptr].Size))
X datasize = IFFStack[IFFptr].Size;
X }
X if ((error=ReadStream(iff, (UBYTE *)data, datasize))<=0)
X if (error==0)
X return IFFERR_EOF;
X else
X return IFFERR_READ;
X IFFStack[IFFptr].Size -= datasize;
X if ((IFFStack[IFFptr].Size==0) && AlignStream(iff))
X return IFFERR_NOTIFF;
X return datasize;
X}
X
Xlong
XPushChunk(
X struct IFF *iff,
X long type,
X long id,
X long size)
X{
X long t_type = type;
X
X geta4();
X TraceCall;
X if (WriteStream(iff, (UBYTE *)&id, 8L))
X return IFFERR_WRITE;
X if (t_type!=0L) {
X if (WriteStream(iff, (UBYTE *)&t_type, 4L))
X return IFFERR_WRITE;
X IFFStack[++IFFptr].Size=4;
X } else {
X IFFStack[++IFFptr].Size=0;
X }
X return 0L;
X}
X
Xlong
XPopChunk(struct IFF *iff)
X{
X long offset;
X long size;
X
X geta4();
X TraceCall;
X offset = IFFStack[IFFptr].Size;
X if (SeekStream(iff, -offset-4L))
X return IFFERR_SEEK;
X size = IFFStack[IFFptr].Size;
X if (WriteStream(iff, (UBYTE *)&size, 4L))
X return IFFERR_READ;
X if (IFFptr)
X IFFStack[--IFFptr].Size+=IFFStack[IFFptr+1].Size+8L;
X if (SeekStream(iff, offset))
X return IFFERR_SEEK;
X if (IFFStack[IFFptr+1].Size%2) {
X if (WriteStream(iff, (UBYTE *)"", 1L))
X return IFFERR_READ;
X IFFStack[IFFptr].Size++;
X }
X return 0L;
X}
X
Xlong
XParseIFF(struct IFF *iff, long control)
X{
X struct IFFParseBase *IFFParseBase;
X long error;
X long type = 0L;
X long id;
X long size;
X
X geta4();
X TraceCall;
X if (control==IFFPARSE_RAWSTEP) {
X if (IFFptr && IFFStack[IFFptr].Size==0) {
X IFFptr--;
X iff->current.cn_ID = 0L;
X return IFFERR_EOC;
X } else if (IFFptr && IFFStack[IFFptr].Complex==0) {
X iff->current.cn_ID = 0L;
X if (SeekStream(iff, (long)(IFFStack[IFFptr].Size+((IFFStack[IFFptr].Size)&1))))
X return IFFERR_SEEK;
X IFFptr--;
X return IFFERR_EOC;
X }
X
X if ((error=ReadStream(iff, (UBYTE *)&id, 4L))<=0)
X if (error==0)
X return IFFERR_EOF;
X else
X return IFFERR_READ;
X
X if (!GoodID(id))
X return IFFERR_NOTIFF;
X
X if ((error=ReadStream(iff, (UBYTE *)&size, 4L))<=0)
X if (error==0)
X return IFFERR_EOF;
X else
X return IFFERR_READ;
X
X if ((id==ID_FORM
X || id==ID_PROP
X || id==ID_CAT
X || id==ID_LIST)
X && ReadStream(iff, (UBYTE *)&type, 4L)<=0)
X return IFFERR_READ;
X
X
X if (type!=0L) {
X IFFStack[IFFptr].Size -= size + (size%2) + 8L;
X IFFStack[++IFFptr].Size = size - 4L;
X IFFStack[IFFptr].Complex = 1;
X iff->current.cn_Type = type;
X } else {
X IFFStack[IFFptr].Size -= size + (size%2) + 8L;
X IFFStack[++IFFptr].Size = size;
X IFFStack[IFFptr].Complex = 0;
X }
X iff->current.cn_ID = id;
X iff->current.cn_Size = size;
X iff->current.cn_Scan = ((type!=0) ? 4 : 0);
X return SUCCESS;
X } else
X return FAILED;
X}
X
Xstruct ContextNode*
XCurrentChunk(struct IFF *iff)
X{
X geta4();
X TraceCall;
X return &iff->current;
X}
END_OF_FILE
if test 11025 -ne `wc -c <'sources/handleiff.c'`; then
echo shar: \"'sources/handleiff.c'\" unpacked with wrong size!
fi
# end of 'sources/handleiff.c'
fi
echo shar: End of archive 2 \(of 2\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked both archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
--
Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
Mail comments to the moderator at <amiga-request@uunet.uu.net>.
Post requests for sources, and general discussion to comp.sys.amiga.misc.